package com.timber.tableModels;

import java.util.Vector;

import com.timber.util.ColumnSortDescriptor;
import com.timber.util.SLTableModel;
import com.timber.util.InvetoryBean;

public class InventoryTableModel  extends SLTableModel {

	
	 protected static Vector			v = new Vector();
	 protected static ColumnSortDescriptor[]	defaultSortCols;
	 private static final long serialVersionUID = 1L;
	 
	 static
	  {
		 cm = new InvColumnManager();
		 //cm = InvColumnManager.getInstance();
		 v.add( cm.getByIdClone( InvColumnManager.ITEM_ID ) );
		 v.add( cm.getByIdClone( InvColumnManager.TIMBER_NAME  ) );
		 v.add( cm.getByIdClone( InvColumnManager.TIMBER_CLASS  ) );
		 v.add( cm.getByIdClone( InvColumnManager.TIMBER_LENGTH  ) );
		 v.add( cm.getByIdClone( InvColumnManager.TIMBER_WIDTH  ) );
		 v.add( cm.getByIdClone( InvColumnManager.PURCHASE_QTY ) );
		 v.add( cm.getByIdClone( InvColumnManager.PURCHASE_PRICE ) );
		 v.add( cm.getByIdClone( InvColumnManager.SOLD_QTY ) );
		// v.add( cm.getByIdClone( InvColumnManager.SOLD_PRICE ) );
		 v.add( cm.getByIdClone( InvColumnManager.PURCHASE_DATE ) );
		 v.add( cm.getByIdClone( InvColumnManager.CHILD_COUNT ) );
		 v.add( cm.getByIdClone( InvColumnManager.SUPPLIER_NAME ) );
		 //defaultSortCols = new ColumnSortDescriptor[ 1 ];
		 //defaultSortCols[ 0 ] = new ColumnSortDescriptor( InvColumnManager.ITEM_ID,PVTableModel.PRIMARY,true,PVConvert.STRING );
		 
	  }
	 
	 
	 
	public Object getFieldAt(Object obj, int c) {
		
		Object ret = null;
		
		if( obj != null )
		{
			int id = getColumnId( c );	
			InvetoryBean item = (InvetoryBean)obj;
			switch(id)
			{
			
			case InvColumnManager.ITEM_ID:
				ret =item.getItemId();			
				break;
			case InvColumnManager.TIMBER_NAME:
				ret =item.getTimberName();			
				break;
				
			case InvColumnManager.TIMBER_CLASS:
				ret =item.getTClass();			
				break;
				
			case InvColumnManager.TIMBER_LENGTH:

				ret =new Double( item.getLenght());
				
				break;
			case InvColumnManager.TIMBER_WIDTH:

				ret =new Double(item.getWidth());
				
				break;
			case InvColumnManager.PURCHASE_QTY:

				ret =new Double(item.getPQuantity());
				
				break;
			case InvColumnManager.SOLD_QTY:

				ret =new Double(item.getSQuantity());
				
				break;
			case InvColumnManager.PURCHASE_DATE:

				ret =item.getPurchaseDate();
				
				break;
			case InvColumnManager.CHILD_COUNT:

				ret =new Double(item.getChildId());
				
				break;
			case InvColumnManager.SUPPLIER_NAME:

				ret =new Double(item.getSupplierId());
				
			
			}
			
		}
		
		return ret;
	}

	  public InventoryTableModel()
	  {
	    super( 0, v );
	   // setDefaultSortCols( defaultSortCols );
	    //setAlterBgOnSort();
	  }

	  public InventoryTableModel( Vector dataVector )
	  {
	    super( dataVector, v );
	   // setDefaultSortCols( defaultSortCols );
	   // setAlterBgOnSort();
	  }

	
}
